//js url赛选
// -------------------------------------------------------------------------
$(document).ready(function(){
    $("[search_id='list']").click();
    $("[tval]").click(function(){
        var obj = GetRequest();
        obj['url']="http://"+window.location.host+window.location.pathname;
        obj[$(this).attr('tname')] = $(this).attr('tval');
        window.location.href = createUrl(obj);
    });
});
// 获取url中的参数，并返回一个对象
function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = {};
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
        }
    }
    return theRequest;
};
// 生成一个带参数的url
function createUrl(obj) {
    var length = obj && obj.length,
        idx = 0,
        url = obj.url + '?';
    for (var key in obj) {
        if (key != 'url' && obj[key] !== null) {
            url += (key + '=' + encodeURIComponent(obj[key]) + '&');
        }
    }
    return url.substring(0, url.lastIndexOf('&'));
}
